home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2583 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.6 KB

  1. Path: news.ccs.queensu.ca!news
  2. From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
  3. Newsgroups: comp.lang.c++,comp.lang.pascal.delphi.misc
  4. Subject: Re: C++ with Zapp vs. Delphi
  5. Date: Thu, 18 Jan 1996 15:33:13 GMT
  6. Organization: Queen's University, Kingston
  7. Message-ID: <30fe666e.3349285@130.15.126.54>
  8. References: <4coar6$d4n@sun4.bham.ac.uk> <4coip7$69s@news1.usa.pipeline.com> <DBk8wg2yqjbB083yn@iaccess.za> <4d7pmb$48c8@tigger.cc.uic.edu> <4dk38h$gdr@merlin.delphi.com> <4dksp1$3d6c@tigger.cc.uic.edu>
  9. NNTP-Posting-Host: djm.mast.queensu.ca
  10. X-Newsreader: Forte Agent .99c/16.141
  11.  
  12. On 18 Jan 1996 07:27:29 GMT, olczyk@sunphy1 (Jung Oh) wrote:
  13.  
  14. >But it does raise an interesting problem.
  15. >How do you write a class SortedList which maintains a list of objects which 
  16. >have a method CompareTo. This lists keeps the objects in sorted order based
  17. >on CompareTo.  
  18. ...
  19. >If you have MI it's easy. Just create a class called SortedObject with
  20. >a virtual method called CompareTo. Store objects of that type in the list.
  21.  
  22. The way this is done in Delphi is to create a descendant of the
  23. SortedList that overrides the compare method.  Instead of forcing you
  24. to only put SortedObjects in the list, this allows you to put anything
  25. there, even non-objects like integers or strings or empty holes, if
  26. that suits your fancy.
  27.  
  28. There's not a big difference, but I think this is a little bit
  29. preferable.  It makes it clear that it's up to the list to know about
  30. sorting, not up to the object.  That way you can easily put the same
  31. object in multiple lists with different sorting rules.
  32.  
  33. Duncan Murdoch
  34.  
  35. P.S. Your newsreader isn't configured properly; it's not giving a
  36. valid return address (see above).
  37.